﻿using System.Runtime.Serialization;

namespace Needle.Bus.Messages.Management
{
    [DataContract]
    public class FailMessage : ControlMessage
    {
        /// <summary>
        /// Creates a new FailMessage
        /// </summary>
        /// <param name="failCode">Machine-readable failure code</param>
        /// <param name="description">Human readable error message</param>
        /// <param name="cause">Message causing the failure</param>
        public static FailMessage Create(string failCode, string description, ICorrelation cause)
        {
            return new FailMessage
            {
                CorrelationId = cause == null ? null : cause.IdForCorrelation,
                FailCode = failCode,
                Description = description
            };
        }
        /// <summary>
        /// Machine-readable failure code
        /// </summary>
        [DataMember]
        public string FailCode { get; set; }
        /// <summary>
        /// Human readable error message
        /// </summary>
        [DataMember]
        public string Description { get; set; }

    }
}
